<template>
	<view>
		<!-- 登录弹框 -->
		<view v-if="!isLogin" class="login-mask">
			<view class="login-dialog">
				<view class="login-title">请先登录</view>
				<view class="login-desc">登录后可查看您的个人中心和加盟相关功能</view>
				<button class="login-btn" @click="doLogin">微信一键登录</button>
			</view>
		</view>
		<view v-else class="mine-page">
			<!-- 个人信息卡片 -->
			<view class="profile-card">
				<image class="avatar" src="/static/tabbar/home-active.png" mode="aspectFill" />
				<view class="profile-info">
					<view class="profile-name">喻大海</view>
					<view class="profile-phone">188****1459</view>
				</view>
			</view>
			<!-- 加盟申请进度 -->
			<view class="section-title">我的加盟申请</view>
			<view v-if="records.length" class="apply-list">
				<view v-for="(item, idx) in records" :key="idx" class="apply-item">
					<view class="apply-row">
						<text>城市：</text>
						{{ item.city }}
					</view>
					<view class="apply-row">
						<text>状态：</text>
						{{ item.status }}
					</view>
					<view class="apply-row">
						<text>申请时间：</text>
						{{ item.time }}
					</view>
				</view>
			</view>
			<view v-else class="empty-tip">暂无加盟申请记录</view>
			<!-- 快捷功能入口 -->
			<view class="section-title">快捷功能</view>
			<view class="quick-entry">
				<view class="quick-btn" @click="goApply">
					<image src="/static/tabbar/fee-active.png" class="quick-icon" />
					<view>申请加盟</view>
				</view>
				<view class="quick-btn" @click="goFaq">
					<image src="/static/tabbar/interlocution-active.png" class="quick-icon" />
					<view>加盟问答</view>
				</view>
				<view class="quick-btn" @click="goStores">
					<image src="/static/tabbar/home-active.png" class="quick-icon" />
					<view>我的门店</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			isLogin: false,
			records: [
				{ city: '广州', status: '审核中', time: '2024-05-01 10:00' },
				{ city: '深圳', status: '已通过', time: '2024-04-15 14:30' }
			]
		};
	},
	methods: {
		doLogin() {
			// 调用微信小程序登录API
			uni.login({
				provider: 'weixin',
				success: (res) => {
					// 这里可对接后端，获取用户信息
					this.isLogin = true;
				},
				fail: () => {
					uni.showToast({ title: '登录失败', icon: 'none' });
				}
			});
		},
		goApply() {
			uni.navigateTo({ url: '/pages/join/join' });
		},
		goFaq() {
			uni.navigateTo({ url: '/pages/policy/policy' });
		},
		goStores() {
			uni.navigateTo({ url: '/pages/stores/stores' });
		}
	}
};
</script>

<style scoped>
.mine-page {
	padding: 32rpx;
	background: #f8f9fa;
	min-height: 100vh;
}
.profile-card {
	display: flex;
	align-items: center;
	background: #fff;
	border-radius: 24rpx;
	box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
	padding: 32rpx;
	margin-bottom: 32rpx;
}
.avatar {
	width: 120rpx;
	height: 120rpx;
	border-radius: 50%;
	object-fit: cover;
	margin-right: 32rpx;
	border: 2rpx solid #de9190;
}
.profile-info {
	display: flex;
	flex-direction: column;
	gap: 8rpx;
}
.profile-name {
	font-size: 36rpx;
	font-weight: bold;
	color: #de9190;
}
.profile-phone {
	font-size: 28rpx;
	color: #888;
}
.section-title {
	font-size: 32rpx;
	font-weight: bold;
	color: #de9190;
	margin: 32rpx 0 16rpx 0;
}
.apply-list {
	display: flex;
	flex-direction: column;
	gap: 24rpx;
}
.apply-item {
	background: #fff;
	border-radius: 16rpx;
	box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
	padding: 24rpx;
}
.apply-row {
	font-size: 28rpx;
	color: #333;
	margin-bottom: 8rpx;
}
.empty-tip {
	color: #aaa;
	font-size: 28rpx;
	text-align: center;
	margin: 32rpx 0;
}
.quick-entry {
	display: flex;
	gap: 32rpx;
	margin-top: 16rpx;
}
.quick-btn {
	flex: 1;
	background: #fff;
	border-radius: 16rpx;
	box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 24rpx 0;
	font-size: 28rpx;
	color: #de9190;
	font-weight: bold;
	cursor: pointer;
}
.quick-icon {
	width: 64rpx;
	height: 64rpx;
	margin-bottom: 8rpx;
}

.login-mask {
	position: fixed;
	left: 0;
	top: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.25);
	z-index: 9999;
	display: flex;
	align-items: center;
	justify-content: center;
}
.login-dialog {
	background: #fff;
	border-radius: 32rpx;
	padding: 64rpx 48rpx 48rpx 48rpx;
	min-width: 500rpx;
	max-width: 90vw;
	box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.12);
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 32rpx;
}
.login-title {
	font-size: 36rpx;
	font-weight: bold;
	color: #de9190;
	margin-bottom: 16rpx;
}
.login-desc {
	font-size: 28rpx;
	color: #666;
	margin-bottom: 32rpx;
	text-align: center;
}
.login-btn {
	background: #de9190;
	color: #fff;
	border: none;
	border-radius: 32rpx;
	font-size: 28rpx;
	padding: 16rpx 48rpx;
	font-weight: bold;
}
</style>
